﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="menetlusinfoRequest", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MenetlusinfoRequest))]
    public class MenetlusinfoRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMenetlusinfoRequest clazz;
        
        public MenetlusinfoRequestSerializer(IMenetlusinfoRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.NotarId!=null) {
                Writer.WriteStartElement("notar_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotarId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotarIsikukood!=null) {
                Writer.WriteStartElement("notar_isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotarIsikukood))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("algus_kuupaev");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKuupaev))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("lopp_kuupaev");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKuupaev))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="notar_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotarId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notar_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notar_isikukood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotarIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notar_isikukood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="algus_kuupaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfoRequest>algus_kuupaev");
                }
                clazz.AlgusKuupaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kuupaev")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfoRequest>algus_kuupaev", Reader.LocalName);
            }
            if (Reader.LocalName=="lopp_kuupaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfoRequest>lopp_kuupaev");
                }
                clazz.LoppKuupaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kuupaev")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfoRequest>lopp_kuupaev", Reader.LocalName);
            }
        }
    }
}
